package com.zyf.qa.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zyf.qa.pojo.Problem;
import com.zyf.qa.service.impl.ProblemServiceImpl;
import entity.PageResult;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
public class ProblemController {
    @Autowired
    ProblemServiceImpl problemService;

    /**
     * 根据标签ID查询最新问题列表
     * 分页
     *
     * @param labelid
     * @return
     */

    @RequestMapping(value = "/newlist/{labelid}/{pageNum}/{pageSize}", method = RequestMethod.GET)
    public Result findNewListByLabelId(@PathVariable String labelid, @PathVariable int pageNum, @PathVariable int pageSize) {
        List list = new ArrayList();
        list.add(problemService.findNewListByLabelId(labelid, pageNum, pageSize));
        return new Result(true, StatusCode.OK, "查询成功", list);
    }

    /**
     * 根据标签ID查询热门问题列表
     *
     * @param labelid
     * @return
     */
    @RequestMapping(value = "/hotlist/{labelid}/{pageNum}/{pageSize}", method = RequestMethod.GET)
    public Result findHotListByLabelId(@PathVariable String labelid, @PathVariable int pageNum, @PathVariable int pageSize) {
        List list = new ArrayList();
        list.add(problemService.findHotListByLabelId(labelid, pageNum, pageSize));
        return new Result(true, StatusCode.OK, "查询成功", list);
    }
    /**
     * 根据标签ID查询等待回答列表
     * @param labelid
     * @return
     */
    @RequestMapping(value="/waitlist/{labelid}/{pageNum}/{pageSize}",method=RequestMethod.GET)
    public Result findWaitListByLabelId(@PathVariable String labelid,@PathVariable int pageNum, @PathVariable int pageSize){
        List list = new ArrayList();
        list.add(problemService.findWaitListByLabelId(labelid, pageNum, pageSize));
        return new Result(true, StatusCode.OK, "查询成功",list);
    }

}
